#ifndef NEWSETTIGSWINDOW_H
#define NEWSETTIGSWINDOW_H

#include <QtGui>

class SliderWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SliderWidget(QWidget *parent = 0);

signals:
    void valueChanged(int);

private:
    QLineEdit *edit;
    QSlider *slider;

private slots:
    void onEditChanged();
    void onSliderChanged();

};

struct Profiles
{
//    int id;
    QString name;
    int hand[16];
    int arm[10];
    int correct;
};

class NewSettingsWindow : public QWidget
{
    Q_OBJECT

public:
    explicit NewSettingsWindow(QWidget *parent = 0);
    void setDefaulCalibration(QVector<int> cal1, QVector<int> cal2);
    void setSensData(QVector<int>);
    QVector<int> getCommands(){return commands;}
    void setDefaultArmCalibration(QVector<int> vector);
    void setAnglesAndCommands(const QVector<float> &vector);
    void setCommands(const QVector<float> &vector);

    void setProfileSettings();

    int* getManualAgnles() {return angles;}

    void setBoundaries(QVector<int> vec);

signals:
    void windowClosed();
    void gloveCalibrateValueChanged(int ind1, int ind2, int val);
    void armCalibrateValueChanged(int ind, float val);
//    void takeManualAngles(int mas[5]);
    void manualSignal(bool);
    void wristSignal(int ind, int val);
    void useBoundSignal(bool);

private:
    void closeEvent(QCloseEvent *event);
    void loadProfiles();
    void saveProfiles();

    QPushButton *gloveCalibrateBtn;
    QComboBox *profilesBox;
    QPushButton *newBtn, *deleteBtn;
    QRadioButton *radioBtn;
    QCheckBox *useBoundariesBox;

    QVector<Profiles> profilesVector;
//    QMap<short, QLineEdit*> fingerGridMap;
//    QMap<short, QLineEdit*> armGridMap;
    QMap<short, QLineEdit*> settingsMap;
    QMap<int, QSlider*> sliderMap;
    QVector<int> lowCalibrate, highCalibrate;
    QVector<int> currentData, commands;

    QSlider *wristSlider1, *wristSlider2;

    short gloveCount;
    Profiles *currentProfile;
    bool profileIsLoaded;

    int angles[5];
    int boundaries[10];

private slots:
    void onRadioBtn(bool bl);
    void onUseBoundariesBox(bool bl);
    void onProfBoxChanged(int ind);
    void profNameChanged(QString name);
    void onNewBtn();
    void onDeleteBtn();
    void changeGloveCalibtrate();
    void changeArmSettings();
    void onCalibrate();
    void settingsChanged();

    void sliderToEdit();
    void editToSlider();

    void onWristSlider1(int val);
    void onWristSlider2(int val);



//    void onGetManualAngles() {emit takeManualAngles(angles);}

};

#endif // NEWSETTIGSWINDOW_H
